test: cover abstract factory generator keys#421
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR adds targeted generator tests for AbstractFactoryGenerator, improving coverage for char key formatting, default/base-class products, service-provider overload suppression, and primitive key diagnostics.
Changes:
- Adds a scenario for additional char family keys, base-class contract products, default products, and whitespace service-provider method suppression.
- Adds a diagnostic scenario covering incompatible primitive/enum key families and unsupported
doublekey formatting. - Keeps changes scoped to generator test coverage for issue #413.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [AbstractFactoryProduct('\'', typeof(Widget), typeof(DerivedWidget), IsDefaultFamily = true)] | ||
| [AbstractFactoryProduct('\r', typeof(Widget), typeof(DerivedWidget))] | ||
| [AbstractFactoryProduct('\t', typeof(Widget), typeof(DerivedWidget))] | ||
| [AbstractFactoryProduct('x', typeof(Widget), typeof(DerivedWidget))] | ||
| public static partial class CharFactory; | ||
| """; | ||
|
|
||
| var comp = CreateCompilation(source, nameof(FormatsAdditionalCharKeysAndBaseClassProducts)); | ||
| var gen = new AbstractFactoryGenerator(); | ||
| _ = RoslynTestHelpers.Run(comp, gen, out var run, out var updated); | ||
|
|
||
| ScenarioExpect.All(run.Results, result => ScenarioExpect.Empty(result.Diagnostics)); | ||
|
|
||
| var generated = ScenarioExpect.Single(run.Results.SelectMany(result => result.GeneratedSources)); | ||
| var text = generated.SourceText.ToString(); | ||
|
|
||
| ScenarioExpect.Contains("builder.Family('\\\\')", text); | ||
| ScenarioExpect.Contains("builder.Family('\\r')", text); | ||
| ScenarioExpect.Contains("builder.Family('\\t')", text); | ||
| ScenarioExpect.Contains("builder.Family('x')", text); |
Test Results 12 files 12 suites 9m 32s ⏱️ Results for commit d9a142e. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #421 +/- ##
==========================================
+ Coverage 89.89% 95.90% +6.00%
==========================================
Files 551 551
Lines 44186 44186
Branches 6359 6359
==========================================
+ Hits 39722 42377 +2655
+ Misses 1967 1809 -158
+ Partials 2497 0 -2497
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Code Coverage |
Summary
Part of #413.
Validation